<?php
/**
 * @Author: Marte
 * @Date:   2020-04-12 00:49:49
 * @Last Modified by:   Marte
 * @Last Modified time: 2020-04-12 09:38:32
 */
class ObjArray implements \ArrayAccess
{
    public function offsetExists($key){
        return isset($this->$key);
    }

    public function offsetGet($key){
        if(property_exists($this, $key)){
            return $this->$key;
        }else{
            return null;
        }
    }

    public function offsetSet($key, $value){
        $this->$key = $value;
    }

    public function offsetUnset($key){
        unset($this->$key);
    }
}


$obj = new \ObjArray();

$obj->age = 32;
var_dump($obj['age']);
var_dump(isset($obj['age']));
unset($obj['age']);
var_dump($obj['age']);